-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalidate variables cache in SetVariableAsync and in EvaluateExpressionAsync to have actual variables data #2169
base: main
Are you sure you want to change the base?
Conversation
Add Variables cache see PowerShell/PowerShellEditorServices#2169
@andyleejordan Can you please review this one? |
Add Variables cache see PowerShell/PowerShellEditorServices#2169
Add Variables cache see PowerShell/PowerShellEditorServices#2169
Add Variables cache see PowerShell/PowerShellEditorServices#2169 Debugger WIP 15 Catch value modification errors Debugger WIP 15 Debugger eval completion Debugger WIP 14 Add id to document Debugger WIP 13 Remove useless files Debugger WIP 12 Add Variable Test Debugger WIP 11.2 Remove useless comments Debugger WIP 11.1 Change hardcoded parameter to variable remove unused variable from EvaluationTest.testEvaluation Debugger WIP 11 Call clientSession.terminateDebugging() on dispose Change PowerShellDebuggerVariableValue supertype to XNamedValue update formatting Test: Update BreakpointTest Add EvaluationTest Add StepTest Debugger WIP 10 Add tests Add BreakpointTest Debugger WIP 9 Set variable value Debugger WIP 8 run project file instead hardcoded file set all breakpoints on start Debugger WIP 7 Step Over/In/Out support Terminate support Debugger WIP 6 Conditional and log support Debugger WIP 5 IDE Breakpoints support Resume (continue) support Debugger WIP 5 Variable list Complex objects Debugger WIP 3 variable list eval Debugger WIP 2 Debugger WIP
Add Variables cache see PowerShell/PowerShellEditorServices#2169 Debugger WIP 15 Catch value modification errors Debugger WIP 15 Debugger eval completion Debugger WIP 14 Add id to document Debugger WIP 13 Remove useless files Debugger WIP 12 Add Variable Test Debugger WIP 11.2 Remove useless comments Debugger WIP 11.1 Change hardcoded parameter to variable remove unused variable from EvaluationTest.testEvaluation Debugger WIP 11 Call clientSession.terminateDebugging() on dispose Change PowerShellDebuggerVariableValue supertype to XNamedValue update formatting Test: Update BreakpointTest Add EvaluationTest Add StepTest Debugger WIP 10 Add tests Add BreakpointTest Debugger WIP 9 Set variable value Debugger WIP 8 run project file instead hardcoded file set all breakpoints on start Debugger WIP 7 Step Over/In/Out support Terminate support Debugger WIP 6 Conditional and log support Debugger WIP 5 IDE Breakpoints support Resume (continue) support Debugger WIP 5 Variable list Complex objects Debugger WIP 3 variable list eval Debugger WIP 2 Debugger WIP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, we looked at this in triage and I liked it. I added to my list for next release but I can at least merge sooner than that. I wanted to double-check FetchStackFramesAndVariablesAsync
(just did) and while I agree it's related to #58 I don't think it'll solve it, but I think the solution for that is doing the same thing except after excecution of a user command in the debugger prompt. So, very similarly fixable. Thanks so much!
Looks like the same issue. I have a hypothesis (not yet checked with the sources): what if a test executes some operation that would cause that exception, but it is currently masked by the fact that PSES doesn't re-evaluate the variables after each step? In that case, it is possible that there's a real error that is hidden from the test. |
I have debugged it and have found that after SetVariable, FetchStackFramesAndVariablesAsync fetches variables with two more variables called "$__psEditorServices_CallStack." And that changes the referenceIds of the scopes. I see two ways of solving this:
|
After a bit of additional digging (disclaimer: I am a supervisor of @Fantoom), we found these lines in the DAP spec:
I am not very sure, but to me it looks like, unfortunately, this PR breaks the spec expectation that the variable ids are preserved between the suspend points (and effectively introduces a new suspend state after any variable evaluation). I'd rely on your judgement, folks, on what to do with that further. We might have to redesign this part, to allow some kind of partial update of the suspend state, preserving the variable ids? |
Add Variables cache see PowerShell/PowerShellEditorServices#2169 Debugger WIP 15 Catch value modification errors Debugger WIP 15 Debugger eval completion Debugger WIP 14 Add id to document Debugger WIP 13 Remove useless files Debugger WIP 12 Add Variable Test Debugger WIP 11.2 Remove useless comments Debugger WIP 11.1 Change hardcoded parameter to variable remove unused variable from EvaluationTest.testEvaluation Debugger WIP 11 Call clientSession.terminateDebugging() on dispose Change PowerShellDebuggerVariableValue supertype to XNamedValue update formatting Test: Update BreakpointTest Add EvaluationTest Add StepTest Debugger WIP 10 Add tests Add BreakpointTest Debugger WIP 9 Set variable value Debugger WIP 8 run project file instead hardcoded file set all breakpoints on start Debugger WIP 7 Step Over/In/Out support Terminate support Debugger WIP 6 Conditional and log support Debugger WIP 5 IDE Breakpoints support Resume (continue) support Debugger WIP 5 Variable list Complex objects Debugger WIP 3 variable list eval Debugger WIP 2 Debugger WIP
Add Variables cache see PowerShell/PowerShellEditorServices#2169 Debugger WIP 15 Catch value modification errors Debugger WIP 15 Debugger eval completion Debugger WIP 14 Add id to document Debugger WIP 13 Remove useless files Debugger WIP 12 Add Variable Test Debugger WIP 11.2 Remove useless comments Debugger WIP 11.1 Change hardcoded parameter to variable remove unused variable from EvaluationTest.testEvaluation Debugger WIP 11 Call clientSession.terminateDebugging() on dispose Change PowerShellDebuggerVariableValue supertype to XNamedValue update formatting Test: Update BreakpointTest Add EvaluationTest Add StepTest Debugger WIP 10 Add tests Add BreakpointTest Debugger WIP 9 Set variable value Debugger WIP 8 run project file instead hardcoded file set all breakpoints on start Debugger WIP 7 Step Over/In/Out support Terminate support Debugger WIP 6 Conditional and log support Debugger WIP 5 IDE Breakpoints support Resume (continue) support Debugger WIP 5 Variable list Complex objects Debugger WIP 3 variable list eval Debugger WIP 2 Debugger WIP
@ForNeVeR I have this on my radar, just getting back to work after breaking my hand! Will reply more in depth soon. |
…Services.Services.DebugService.SetVariableAsync and in Microsoft.PowerShell.EditorServices.Services.DebugService.EvaluateExpressionAsync to invalidate variables cache and use actual variables data.
Rebasing to re-run tests, should be OK now. |
@JustinGrote don't forget this part! |
Sorry, I meant to say the test should be fine, not that the pr is ready to be merged |
80b2351
to
9ce8911
Compare
PR Summary
If the user modifies, adds, or removes a variable (e.g., with SetVariable or Evaluate request) and then sends Variables request (which calls GetVariables), they get unmodified variables set from the cached variables field.
I have added FetchStackFramesAndVariablesAsync calls in SetVariableAsync and in EvaluateExpressionAsync to invalidate the cache and get actual data on Variables request
This is probably related to #58, but I am not sure.
PR Context
We are working on adding debugger support to https://github.com/ant-druha/intellij-powershell